package com.wbt.jdk.map;

import java.util.HashSet;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

public class TestTreeMap {

    public static void main(String[] args) {
        ConcurrentHashMap<Integer,String> treeMap = new ConcurrentHashMap<>();
        for (int i =0;i<15;i++){
            treeMap.put(i,String.valueOf(i));
        }
        //treeMap.forEach(System.out::println);
       treeMap.forEach((k,v) ->{
            System.out.println(k +" : " + v);
            //if(k ==7) treeMap.remove(k);
        });
        System.out.println("---------------------------------------------");
        for (Integer k:treeMap.keySet()) {
            if(k ==7) treeMap.remove(k);
            System.out.println(k +" : " + treeMap.get(k));

        }

        System.out.println("---------------------------------------------");
        treeMap.forEach((k,v) ->{
            System.out.println(k +" : " + v);
            //if(k ==7) treeMap.remove(k);
        });
        System.out.println("---------------------------------------------");

        HashSet<Integer> hashSet = new HashSet<>();
        for (int i =0;i<15;i++){
            hashSet.add(i);
        }
        hashSet.forEach(System.out::println);

        Consumer c =  System.out::println;
        c.accept("ddd");
    }
}
